import React from 'react'


import { increment,decrement } from '../../store/countSlice'
import { useDispatch ,useSelector} from 'react-redux'
export default function Count() {
    const dispatch=useDispatch()
    const count=useSelector(state=>state.count.count)
    // const{count}=store.getState().count

    const incrementHandle=()=>{
        dispatch(increment(10))
    }

    const decrementHandle=()=>{
        dispatch(decrement(10))
    }


    const oddIncrementHandle=()=>{
        if (count%2!==0) {
        
        }
    }
    
    const waitIncrementHandle=()=>{
        
    }
  return (
    <div>
        <h1>一个数{count}</h1>
        <button onClick={incrementHandle}>累加</button>
        <button onClick={decrementHandle}>累减</button>
        <button onClick={oddIncrementHandle}>奇数累加</button>
        <button onClick={waitIncrementHandle}>2s后累加</button>
    </div>
  )
}
